﻿@using Matrix.MaKaYunShang.Model.Dto
@model Matrix.MaKaYunShang.Model.Dto.McAccountDto
@{
    ViewBag.Title = "系统数据总览";
    ViewBag.PathToBtn = "/";
    ViewBag.TextBtn = "刷新";
    Layout = "~/Views/Shared/_Layout.cshtml";

    var currentUser = ViewBag.CurrentUser as McAccountDto;
}

<div class="row" style="text-align: center">
    @if (!currentUser.IsHeadquarters)
    {
        <div class="col-lg-3 col-md-6">
            <div class="panel panel-primary">
                <div class="panel-heading">
                    <div class="row">
                        <div class="col-xs-3">
                            <i class="fa fa-comments fa-5x"></i>
                        </div>
                        <div class="col-xs-9 text-right">
                            <div id="divMsgCount" class="huge">0</div>
                            <div>新消息数量</div>
                        </div>
                    </div>
                </div>
                <a href="/Message/List">
                    <div class="panel-footer">
                        <span class="pull-left">查看详情</span>
                        <span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
                        <div class="clearfix"></div>
                    </div>
                </a>
            </div>
        </div>
        <div class="col-lg-3 col-md-6">
            <div class="panel panel-green">
                <div class="panel-heading">
                    <div class="row">
                        <div class="col-xs-3">
                            <i class="fa fa-tasks fa-5x"></i>
                        </div>
                        <div class="col-xs-9 text-right">
                            <div id="divShopCommodityCount" class="huge">0</div>
                            <div>上线的商品数量</div>
                        </div>
                    </div>
                </div>
                <a href="/ShopCommodity/List">
                    <div class="panel-footer">
                        <span class="pull-left">查看详情</span>
                        <span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
                        <div class="clearfix"></div>
                    </div>
                </a>
            </div>
        </div>
        <div class="col-lg-3 col-md-6">
            <div class="panel panel-yellow">
                <div class="panel-heading">
                    <div class="row">
                        <div class="col-xs-3">
                            <i class="fa fa-shopping-cart fa-5x"></i>
                        </div>
                        <div class="col-xs-9 text-right">
                            <div id="divOrdersCount" class="huge">0</div>
                            <div>订单数</div>
                        </div>
                    </div>
                </div>
                <a href="/Orders/List">
                    <div class="panel-footer">
                        <span class="pull-left">查看详情</span>
                        <span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
                        <div class="clearfix"></div>
                    </div>
                </a>
            </div>
        </div>
        <div class="col-lg-3 col-md-6">
            <div class="panel panel-red">
                <div class="panel-heading">
                    <div class="row">
                        <div class="col-xs-3">
                            <i class="fa fa-support fa-5x"></i>
                        </div>
                        <div class="col-xs-9 text-right">
                            <div id="divStaffCount" class="huge">0</div>
                            <div>员工数量</div>
                        </div>
                    </div>
                </div>
                <a href="/McAccounts/List">
                    <div class="panel-footer">
                        <span class="pull-left">查看详情</span>
                        <span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
                        <div class="clearfix"></div>
                    </div>
                </a>
            </div>
        </div>
        <div class="col-lg-3 col-md-6">
            <div class="panel panel-yellow">
                <div class="panel-heading">
                    <div class="row">
                        <div class="col-xs-3">
                            <i class="fa fa-tasks fa-5x"></i>
                        </div>
                        <div class="col-xs-9 text-right">
                            <div class="huge"></div>
                            <div>固定二维码</div>
                        </div>
                    </div>
                </div>
                <div class="panel-footer">
                    <span class="pull-left"></span>
                    <img src="@Url.Action("GenerateQRCode", "Home", new { content = @ViewBag.FixedQrCode })" alt="固定二维码" style="max-height: 200px;" />
                    <div class="clearfix"></div>
                </div>
            </div>
        </div>
        <div class="col-lg-3 col-md-6">
            <div class="panel panel-yellow">
                <div class="panel-heading">
                    <div class="row">
                        <div class="col-xs-3">
                            <i class="fa fa-credit-card fa-5x"></i>
                        </div>
                        <div class="col-xs-9 text-right">
                            <div class="huge">@Model.CanSendCard</div>
                            <div>剩余可发卡劵数量</div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="panel panel-red">
                <div class="panel-heading">
                    <div class="row">
                        <div class="col-xs-3">
                            <i class="fa fa-rmb fa-5x"></i>
                        </div>
                        <div class="col-xs-9 text-right">
                            <div class="huge">@Model.AccountMoney</div>
                            <div>余额</div>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    }
    else
    {
        <div class="col-lg-3 col-md-6">
            <div class="panel panel-yellow">
                <div class="panel-heading">
                    <div class="row">
                        <div class="col-xs-3">
                            <i class="fa fa-credit-card fa-5x"></i>
                        </div>
                        <div class="col-xs-9 text-right">
                            <div class="huge">@Model.CanSendCard</div>
                            <div>剩余可发卡劵数量</div>
                        </div>
                    </div>
                </div>
                <a href="/CloudCards/List">
                    <div class="panel-footer">
                        <span class="pull-left">查看卡券</span>
                        <span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
                        <div class="clearfix"></div>
                    </div>
                </a>
            </div>
        </div>
    }
</div>

@section javascript{
    <script type="text/javascript">
        $(function () {
            getMessageCount();
            getShopCommodityCount();
            getOrderCount();
            getStaffCount();

            $("#ContentHeadBtn").click(function () {
                getMessageCount();
                getShopCommodityCount();
                getOrderCount();
                getStaffCount();
            });
        });

        function getMessageCount() {
            $.ajax({
                type: 'post',
                async: false,
                url: "/Message/GetMessageCount",
                data: {},
                success: function (info) {
                    $("#divMsgCount").html(info);
                }
            });
        }

        function getShopCommodityCount() {
            $.ajax({
                type: 'post',
                async: false,
                url: "/ShopCommodity/GetCount",
                data: {},
                success: function (info) {
                    $("#divShopCommodityCount").html(info);
                }
            });
        }

        function getOrderCount() {
            $.ajax({
                type: 'post',
                async: false,
                url: "/Orders/GetCount",
                data: {},
                success: function (info) {
                    $("#divOrdersCount").html(info);
                }
            });
        }

        function getStaffCount() {
            $.ajax({
                type: 'post',
                async: false,
                url: "/McAccounts/GetCount",
                data: {},
                success: function (info) {
                    $("#divStaffCount").html(info);
                }
            });
        }
    </script>
}